﻿<UserControl
    x:Name="rootControl"
    x:Class="Wimm.CustomContols.MoneyInputControl"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:local="using:Wimm.CustomContols"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
    xmlns:conv="using:Wimm.Common.Converters"
    xmlns:interactivity="using:Microsoft.Xaml.Interactivity"
    xmlns:interop="using:Windows.UI.Xaml.Interop"
    mc:Ignorable="d"
    d:DesignHeight="400"
    d:DesignWidth="845">
    <UserControl.Resources>
        <conv:BooleanToVisibilityConverter x:Key="BoolToVis"/>
        <conv:DecimalConverter x:Key="DecimalConverter"/>
    </UserControl.Resources>
    <Grid x:Name="LayoutRoot" Margin="0 0 0 0">
        <Grid.ColumnDefinitions>
            <ColumnDefinition Width="Auto" />
            <ColumnDefinition Width="*"/>
            <ColumnDefinition Width="Auto" />
        </Grid.ColumnDefinitions>
        <Grid.RowDefinitions>
            <RowDefinition Height="0.2*"/>
            <RowDefinition />
        </Grid.RowDefinitions>
        <TextBlock FontSize="36" Grid.Column="0"  VerticalAlignment="Center" Margin="5 0 25 0" x:Uid="Amount"></TextBlock>
        <Grid Grid.Column="1"  >
            <Grid.ColumnDefinitions>
                <ColumnDefinition Width="Auto"></ColumnDefinition>
                <ColumnDefinition Width="Auto"></ColumnDefinition>
                <ColumnDefinition Width="Auto"></ColumnDefinition>
                <ColumnDefinition Width="*"></ColumnDefinition>
                <ColumnDefinition Width="Auto"></ColumnDefinition>
            </Grid.ColumnDefinitions>
            <TextBox VerticalAlignment="Center" MinWidth="100" MaxWidth="150" Grid.Column="0" HorizontalAlignment="Left" Margin="0 0 25 0" 
                     Text="{Binding Amount,UpdateSourceTrigger=PropertyChanged,Mode=TwoWay,Converter={StaticResource DecimalConverter}}">
                <interactivity:Interaction.Behaviors>
                    <local:TextBoxBehavior AllowDecimal="True"/>
                </interactivity:Interaction.Behaviors>
            </TextBox>
            <TextBlock FontSize="36" Grid.Column="1"  VerticalAlignment="Center" Margin="5 0 5 0" x:Uid="Comment"/>
            <TextBox IsSpellCheckEnabled="True" VerticalAlignment="Center" Text="{Binding Comment, Mode=TwoWay}" 
                     HorizontalAlignment="Stretch" Grid.Column="3"></TextBox>
            <AppBarToggleButton Grid.Column="4" Icon="More"  VerticalAlignment="Center"
                                IsChecked="{Binding ElementName=extendedPropertiesRow,Mode=TwoWay,Path=Visibility,Converter={StaticResource BoolToVis}}"></AppBarToggleButton>
        </Grid>
        <AppBarToggleButton IsCompact="True" Icon="Add" Grid.Column="2" 
                            Command="{Binding ElementName=rootControl, Path=AddButtonCommand}">
        </AppBarToggleButton>
        <Grid Grid.Row="1" Grid.ColumnSpan="3" Visibility="Collapsed"  x:Name="extendedPropertiesRow">
            <Grid.ColumnDefinitions>
                <ColumnDefinition Width="0.5*"/>
                <ColumnDefinition Width="0.5*"/>
            </Grid.ColumnDefinitions>
            <Grid.RowDefinitions>
                <RowDefinition/>
                <RowDefinition/>
                <RowDefinition/>
                <RowDefinition/>
            </Grid.RowDefinitions>
            <TextBlock FontSize="16" Margin="5" x:Uid="Date"/>
            <TextBlock Grid.Column="1" Margin="5" FontSize="16" x:Uid="Source"/>
            <DatePicker Date="{Binding Time,Mode=TwoWay}" Margin="5" DayFormat="{}{day.integer} ({dayofweek.abbreviated})" Grid.Row="1" Grid.Column="0"></DatePicker>
            <ComboBox HorizontalAlignment="Left" MinWidth="200" Grid.Row="1" Grid.Column="1">
                <ComboBoxItem IsSelected="True">
                    <StackPanel Orientation="Horizontal">
                        <Image Source="IconIncome/cash.png" Height="50"></Image>
                        <TextBlock x:Uid="Cash" HorizontalAlignment="Center" VerticalAlignment="Center"></TextBlock>
                    </StackPanel>
                </ComboBoxItem>
                <ComboBoxItem>
                    <StackPanel Orientation="Horizontal">
                        <Image Source="IconIncome/credit_card.png" Height="50"></Image>
                        <TextBlock x:Uid="Card" HorizontalAlignment="Center" VerticalAlignment="Center"></TextBlock>
                    </StackPanel>
                </ComboBoxItem>
            </ComboBox>
            <TextBlock  Grid.Row="2"  Grid.ColumnSpan="2" FontSize="16" Margin="5" x:Uid="Comment"/>
            <TextBox Margin="5 5 25 25" Grid.Row="3" Grid.ColumnSpan="2" Text="{Binding Comment, Mode=TwoWay}"></TextBox>
        </Grid>
    </Grid>
</UserControl>
